<?php

require dirname(__FILE__) . "/../classes/imageClass.php";
require dirname(__FILE__) . "/../classes/albumClass.php";
require dirname(__FILE__) . "/../classes/connectionFactoryClass.php";
require dirname(__FILE__) . "/../classes/imageDao.php";
require dirname(__FILE__) . "/../classes/albumDao.php";

$idUser = $_SESSION['userId'];
$image = new ImageClass();
$album = new AlbumClass();
$c = new ConnectionFactory();
$db = $c->getConnection();
$imageDao = new imageDao($db);
$albumDao = new albumDao($db);
if (isset($_GET['album'])) {
    $idAlbum = $_GET['album'];


    $allPhotos = Array();

    //procura pelo id do album
    $albumlist = $albumDao->getAlbuns($idUser, $idAlbum);
    $allPhotos[0] = $imageDao->getAllPhotosByAlbum($idAlbum);
} else {
    //retorna todos os albuns

    $albumlist = $albumDao->getAlbuns($idUser, '');

    if ($albumlist) {
        //cria uma array com fotos separadas por album 
        $i = 0;
        foreach ($albumlist as $l) {
            echo $l->getIdAlbum();

            $allPhotos[$i] = $imageDao->getAllPhotosByAlbum($l->getIdAlbum());
            $i++;
        }
    }
}
?>
